﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;

namespace MediawikiSPMigratorClass
{
    public static class LogData
    {
        public static void WriteToLog(string Message)
        {
            string logFilePath = string.Empty;
            bool writingToCDrive = false;
            if (ConfigurationManager.AppSettings["LogFilePath"] == null)
            { 
                logFilePath = @"C:\";
            }
            else
            { logFilePath = ConfigurationManager.AppSettings["LogFilePath"]; }
            
            string logFile = Path.Combine(logFilePath, "MigratorLog_" + DateTime.Now.ToString("ddMMMyyyy") + ".log");

            string logMessage = DateTime.Now.ToLongTimeString() + ": " + Message + "\r\n";
            if (File.Exists(logFile))
            { File.AppendAllText(logFile, logMessage); }
            else
            { File.WriteAllText(logFile, logMessage); }
        }
    }
}
